package Work07;

import java.util.Objects;

public class Student {
    /*定义学生类包含学号、姓名和成绩三个属性；*/
    private int ID;
    private String name;
    private double score;

    public Student() {
    }

    public Student(int ID, String name, double score) {
        this.ID = ID;
        this.name = name;
        this.score = score;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Work07.Student{" +
                "ID=" + ID +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    public Student(String name, double score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return ID == student.ID;
    }

    @Override
    public int hashCode() {
        return Objects.hash(ID);
    }
}
